package com.vik.webgallery.beans;

import java.io.File;
import java.util.List;


public class Gallery extends BaseBean {

	
	private String name;
	
	private String rootFolder;
	
	private long ownerId;
	
	private User owner;
	
	private String previewFileName;
	
	private List<Photo> photos;

	
	public Gallery(){
		regenerateId();
	}
	
	public Gallery(String name, String rootFolder, User owner){
		this.name = name;
		this.rootFolder = rootFolder;
		this.owner = owner;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRootFolder() {
		return rootFolder;
	}

	public void setRootFolder(String rootFolder) {	
		this.rootFolder = rootFolder.toLowerCase().replaceAll("[^a-z0-9-]", "").replaceAll("\\s", "-");
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}
	
	public void setOwnerId(long ownerId){
		this.ownerId = ownerId;
	}

	public long getOwnerId(){
		return this.ownerId;
	}
	
	public List<Photo> getPhotos() {
		return photos;
	}

	public void setPhotos(List<Photo> photos) {
		this.photos = photos;
	}
	
	
	
	public String getPreviewFileName() {
		return previewFileName;
	}

	public void setPreviewFileName(String previewFileName) {
		this.previewFileName = previewFileName;
	}

	public void deleteFolders(String basePath){
		File f = new File(basePath + File.separator + owner.getUserName() + File.separator + rootFolder + File.separator + "thumbnails");
		f.delete();
		f = new File(basePath + File.separator + owner.getUserName() + File.separator + rootFolder + File.separator);
		f.delete();
	}
	
	
	
}
